import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    crsfToken: ''
  },
  mutations: {
    setCsrf (state, val) {
      state.crsfToken = val
    }
  },
  modules: {
    user
  },
  plugins: [createPersistedState({
    // 指定存在sessionStorage中
    storage: window.localStorage
  })]
})

export default store
